/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Bussiness;

import DatabaseAccess.DBHelper;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Vector;

/**
 *
 * @author Nlanh_BN
 */
public class Users {
    private String username;
    private String pass;
    private String status;

    public String getPass() {
        return pass;
    }

    public void setPass(String pass) {
        this.pass = pass;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }
    
    
    public Users(){}
    public Users(String user, String pass, String status){
        this.setUsername(username);
        this.setPass(pass);
        this.setStatus(status);
    }
    
    public Vector getAllAccount() throws SQLException
    {
        Vector v = new Vector();
        try{
            ResultSet rs = DBHelper.executeQuery("sp_getAllAcount");
            while(rs.next())
            {
                Users u = new Users();
                u.setUsername(rs.getString(1));
                u.setPass(rs.getString(2));
                u.setStatus(rs.getString(3));
                v.add(u);
            }
        }catch(SQLException ex){}
        return v;
    }
    public static int changePass(Users u) throws SQLException
    {
        int i=0;
        try
        {
            Vector paramList=new Vector();
            paramList.add(u.getUsername());
            paramList.add(u.getPass());
            i=DBHelper.executeUpdate("changePass",paramList);
        }
        catch(SQLException sqlex)
        {
            
        }
        return i;
    }
}
